﻿using Microsoft.AspNetCore.Http;

using System.Data;
using UtilsCache;
using UtilsORM;
using UtilsORM.MySqlData;

////using System.Web.Script.Serialization;

namespace GatewayServerService.Data
{
    public class DBIotDeviceValueLog
    {



        public iot_device getDevice(string dguid)
        {
            EFYihongIotContext ef = new EFYihongIotContext();
            return ef.iot_device.Where(c => c.d_guid == dguid).FirstOrDefault();
        }



        /// <summary>
        /// m_attribute 1,2
        /// </summary>
        /// <param name="cguid"></param>
        /// <returns></returns>
        public List<iot_device> getDeviceBy12List(string cguid)
        {
            EFYihongIotContext ef = new EFYihongIotContext();
            return (from d in ef.iot_device
                    join m in ef.iot_device_model on d.d_model_guid equals m.m_guid
                    where d.d_status == 0 && m.m_status == 0 && (m.m_attribute == 1 || m.m_attribute == 2) && d.d_c_guid == cguid
                    select d).ToList();

        }


    }
}
